From: Florian Müllner Date: Tue, 3 Mar 2015 01:04:37 +0000 (+0100) Subject: calendar: Respect session mode for section visibility X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~1601 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=313ee70cf7178cb2dd882400bc3c3ba8d21527d5;p=gnome-shell.git calendar: Respect session mode for section visibility It doesn't make much sense to show a section if it must remain empty due to the session mode - there won't be any events if the session mode disallows events, or notifications if those are disallowed. So take the session mode into account and update the sections' visibility accordingly. https://bugzilla.gnome.org/show_bug.cgi?id=745494 --- diff --git a/js/ui/calendar.js b/js/ui/calendar.js index 42f0007f6..1c47b74e7 100644 --- a/js/ui/calendar.js +++ b/js/ui/calendar.js @@ -1269,6 +1269,12 @@ const MessageListSection = new Lang.Class({ this._list.connect('actor-added', Lang.bind(this, this._sync)); this._list.connect('actor-removed', Lang.bind(this, this._sync)); + let id = Main.sessionMode.connect('updated', + Lang.bind(this, this._sync)); + this.actor.connect('destroy', function() { + Main.sessionMode.disconnect(id); + }); + this._messages = new Map(); this._date = new Date(); this.empty = true; @@ -1284,6 +1290,10 @@ const MessageListSection = new Lang.Class({ this.emit('key-focus-in', actor); }, + get allowed() { + return true; + }, + setDate: function(date) { if (_sameDay(date, this._date)) return; @@ -1391,8 +1401,8 @@ const MessageListSection = new Lang.Class({ return _sameDay(this._date, today); }, - _syncVisible: function() { - this.actor.visible = !this.empty; + _shouldShow: function() { + return !this.empty; }, _sync: function() { @@ -1404,7 +1414,7 @@ const MessageListSection = new Lang.Class({ this.emit('empty-changed'); this._closeButton.visible = this._canClear(); - this._syncVisible(); + this.actor.visible = this.allowed && this._shouldShow(); } }); Signals.addSignalMethods(MessageListSection.prototype); @@ -1430,6 +1440,10 @@ const EventsSection = new Lang.Class({ this._eventSource.connect('changed', Lang.bind(this, this._reloadEvents)); }, + get allowed() { + return Main.sessionMode.showCalendarEvents; + }, + _updateTitle: function() { let now = new Date(); if (_sameDay(this._date, now)) { @@ -1521,8 +1535,8 @@ const EventsSection = new Lang.Class({ this._reloadEvents(); }, - _syncVisible: function() { - this.actor.visible = !this.empty || !this._isToday(); + _shouldShow: function() { + return !this.empty || !this._isToday(); }, _sync: function() { @@ -1549,9 +1563,11 @@ const NotificationSection = new Lang.Class({ })); this.actor.connect('notify::mapped', Lang.bind(this, this._onMapped)); + }, - Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated)); - this._sessionUpdated(); + get allowed() { + return Main.sessionMode.hasNotifications && + !Main.sessionMode.isGreeter; }, _sourceAdded: function(tray, source) { @@ -1627,11 +1643,12 @@ const NotificationSection = new Lang.Class({ app.activate(); }, - _syncVisible: function() { - this.actor.visible = !this.empty && this._isToday(); + _shouldShow: function() { + return !this.empty && this._isToday(); }, - _sessionUpdated: function() { + _sync: function() { + this.parent(); this._title.reactive = Main.sessionMode.allowSettings; } });